﻿Imports System.Globalization
Imports System.Threading

<ValidationProperty("Text")> _
Partial Class WebForm_ReserveCar_SelectTime
    Inherits System.Web.UI.UserControl

    Protected Sub Page_Init(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Init
        Me.LoadData()
    End Sub

    Protected Sub Page_DataBinding(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.DataBinding
        Me.LoadData()
    End Sub

    Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load

        If Not IsPostBack Then
            Me.LoadData()
        End If

    End Sub

#Region "方法"
    Private Sub LoadData()
        If Me.ddlSelectTime.Items.Count = 0 Then
            Me.BindHour()
        End If
    End Sub

    Private Sub BindHour()
        Dim i As Integer
        Dim dHour As DateTime
        For i = 1 To 24
            dHour = DateAdd("h", i, Date.Today)
            Me.ddlSelectTime.Items.Add(New ListItem(dHour.ToString("tt h" & Me.GetLocalResourceObject("HourWord")), i))
        Next
        Me.ddlSelectTime.Items.Insert(0, New ListItem(Me.GetLocalResourceObject("PleaseChoose"), ""))
    End Sub

    'Public Sub SetHour(ByVal SelectHour As String)
    '    Me.ddlSelectTime.SelectedValue = Me.ddlSelectTime.Items.FindByValue(SelectHour).Value()
    'End Sub

    'Public Function GetHour() As String
    '    Return Me.ddlSelectTime.SelectedValue
    'End Function
#End Region

    Public Property Text() As String
        Get
            Return Me.Value
        End Get
        Set(ByVal value As String)
            Try
                Me.Value = value
            Catch ex As Exception

            End Try
        End Set
    End Property

    Public Property Value() As String
        Get
            Return Me.ddlSelectTime.SelectedValue
        End Get
        Set(ByVal value As String)
            Me.ddlSelectTime.SelectedIndex = Me.ddlSelectTime.Items.IndexOf(Me.ddlSelectTime.Items.FindByValue(value.Trim()))
        End Set
    End Property

End Class
